package xyz.kail.demo.consul.cloud.consumer;

import com.google.common.collect.Lists;
import xyz.kail.demo.consul.cloud.consumer.client.HelloFeignClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;

/**
 * Created by Kail on 2017/4/6.
 * Copyright(c) ttpai All Rights Reserved.
 */
@RestController
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class ConsulConsumerApplication {

    @Resource
    private HelloFeignClient helloFeignClient;

    @RequestMapping("/home")
    public Object home() {
        return helloFeignClient.say(new Date().toString());
    }

    public static void main(String[] args) {
        ArrayList<String> argsList = Lists.newArrayList(args);

        argsList.add("--server.port=8183");
        argsList.add("--spring.cloud.consul.discovery.register=false");
        argsList.add("--spring.cloud.consul.discovery.instanceId=Consumer");

        SpringApplication.run(ConsulConsumerApplication.class, argsList.toArray(new String[argsList.size()]));
    }

}
